package com.game.adapter;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import com.game.entities.HighScoreData;
import com.game.linerunner.R;

//TODO LineRunner: modify this to be custom, and implement it.
public class HighScoreListAdapter  extends ArrayAdapter<HighScoreData> {

	    private ArrayList<HighScoreData> items;
	    private Context context;

	    public HighScoreListAdapter(Context context, int textViewResourceId, ArrayList<HighScoreData> items) {
	        super(context, textViewResourceId, items);
	        this.context = context;
	        this.items = items;
	    }

	    public View getView(int position, View convertView, ViewGroup parent) {
	        View view = convertView;
	        if (view == null) {
	            LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	            view = inflater.inflate(R.layout.activity_high_score, null);
	        }

	        HighScoreData item = items.get(position);
	        if (item!= null) {
	            // My layout has only one TextView
//	            TextView itemView = (TextView) view.findViewById(R.id.settings_highScoreContainer);
	            ListView lv = (ListView) view.findViewById(R.id.settings_highScoreContainer);
	            
	            if (lv != null) {
	                // do whatever you want with your string and long
//	            	lv.setText(String.format("%s %d", item.getLength()));
	            }
	         }

	        return view;
	    }
	}
	
	

	